<?php $this->widget('application.extensions.fancybox.fancyboxWidget'); ?>
<script type="text/javascript">
<!--
	$(function(){
		$("#gallery-show").fancybox({
			'padding'			: 0,
			'autoScale'			: true,
			'width'				: '75%',
			'height'			: '75%',
			'transitionIn'		: 'none',
			'transitionOut'		: 'none'
		});
		$(".thumb_img").click(function(){
			var href = $(this).parent().attr('href');
//			alert(href);	
			$(this).parent().parent().parent().siblings('.gallery-item-list').html("loading...");
			$(this).parent().parent().parent().siblings('.gallery-item-list').load(href);
			$(this).parent().parent().parent().siblings('.gallery-item-list').fadeIn('slow');			
			return false;
		});
		$(".thumb_up").click(function(){
			$(this).parent().slideUp('slow');
		});

		$('#comment-panel').tabs(); 

		$("#Category_cate_type").change(function(){
////		alert($(this).val());
		$.getJSON("<?php echo $this->createUrl('children');?>",{'cid':$("#Category_cate_type").val(),"id":"<?php echo isset($_GET['id'])?$_GET['id']:Category::CATEGORY_STORY;?>"},function(msg){
//			alert(msg);
//	var msg = {"7":"\u76f8\u518c","8":"|\uff0d\u6536\u85cf\u7f8e\u56fe","9":"|\uff0d\u592a\u6e56\u7f8e\u666f","11":"|\uff0d\u6f2b\u753b"}		
//			$("#Category_cate_pid").html(msg);
//			dd = "";
			
			var pid = document.getElementById("Category_cate_pid");

			//清除所有已有选项
			while(pid.childNodes.length>0){
				pid.removeChild(pid.childNodes[0]);
			}
			$.each(msg,function(k,v){
//				dd += (k+v);

				
				var option = new Option(v,k);
				pid.options.add(option);
			});
//			alert(dd);
		});
		
	});

//	$("#Category_cate_pid").change(function(){
//		alert($(this).val());
//	});

	$("#cate_submit").button();
	$(".itemsubmit").button().click(function(){
		var name = $(this).siblings("input").val();
		var id = $(this).parent().siblings("input").val();

//		alert(id+name);
		$.get('<?php echo $this->createUrl("quickupdate");?>',{"id":id,"name":name},function(data){
			alert(data);
		});
		
		return false;
	});

//	//增加分类
//	$("#cate_submit").click(function(){
////		alert($("#Category_cate_name").val()+$("#Category_cate_pid").val()+$("#Category_cate_type").val()+$("#Category_cate_order").val()+$(document.getElementsByTagName('iframe')[0].contentWindow.document.body).html());
//		$.post('<?php echo $this->createUrl("updateremote");?>',{
//			'cate_name':$("#Category_cate_name").val(),
//			'cate_pid':$("#Category_cate_pid").val(),
//			'cate_type':$("#Category_cate_type").val(),
//			'cate_order':$("#Category_cate_order").val(),
//			'cate_des':$(document.getElementsByTagName('iframe')[0].contentWindow.document.body).html(),
//			'self':1
//		},function(msg){
//			alert(msg);
//			$(msg).insertBefore($("#categoryList>li:eq(0)"));
//		});
//	});

	$(".itemlist").hover(function(){
//		alert("KKK");
		$(this).children(".quick").fadeIn();
	},function(){
		$(this).children(".quick").fadeOut();
	});

	$(".quickshow").click(function(){
		$(this).parent().siblings(".showitem").slideToggle();
		return false;
	});

	$(".quickshow").next().next().click(function(){			
		item = $(this).parent().parent();
		
//		alert(this.href);
		id = $(this).parent().siblings("input").val();
//		alert(id);
		$.post(this.href,{'id':id,'ajax':1},function(msg){
//			alert(msg);
			if(id == msg){
				item.css({"background-color":"yellow"}).fadeOut();
			}
			
		});
		return false;
	});
	$("#file_remote_links").blur(function(){		
		var link = $(this);		
		var reg = /http:\/\/[\w-]*(\.[\w-]*)+/ig;	//匹配url
		if(link.val()!="" && reg.test($(this).val())){
			//在fileloacl_file_links前的一个label中增加一个<span>
			if(link.siblings("label").find(".append").length == 0){
				link.siblings("label").append("<span class=\"append\"></span>");
			}
			
			link.siblings("label").find(".append").html("正在验证此链接是否有效……");
			$.post('<?php echo $this->createUrl('file/checkremote');?>',{'remoteurl':link.val()},function(data){
//				alert(data);
				link.siblings("label").find(".append").html(data);
			});
		}
	});	
 	});



//-->
</script>
<div class="column1 colborder" style="width:58%;">
<?php echo $this->renderPartial('_form', array('model'=>$model,'cate'=>$cate)); ?>
</div>
<div class="column2 prepend-1" style="margin-left:60%;">
	<ul id="categoryList">
	<?php 
		$this->renderPartial('_item',array('cate'=>$cateModel));
	?>
	</ul>
</div>
<div style="display:none">
	<div id="gallery-items" style="width:600px; height:400px;">
		<div id="comment-panel">
			<ul>
				<li><a href="#tabs-1">图集</a></li>
				<li><a href="#tabs-2">网络地址</a></li>
				<li><a href="#tabs-3">Third</a></li>
			</ul>
			<div id="tabs-1">
			<?php foreach ($gallery as $data):?>
				<?php $this->renderPartial('_gallery',array('data'=>$data));?>
			<?php endforeach; ?>

			</div>
			<div id="tabs-2">
				<div class="row">
					<label for="file_remote_links">远程图片地址：</label><br />
					<input type="text" name="file_remote_links" id="file_remote_links" />
				</div>
			</div>
			<div id="tabs-3">Nam dui erat, auctor a, dignissim quis, sollicitudin eu, felis. Pellentesque nisi urna, interdum eget, sagittis et, consequat vestibulum, lacus. Mauris porttitor ullamcorper augue.</div>
		</div>
		
	   
	</div>
</div>